home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / MoreFiles 1.2.1 / Search.p < prev    next >
Encoding:
Text File  |  1994-07-22  |  3.4 KB  |  80 lines  |  [TEXT/PJMM]

  1. UNIT Search;
  2.  
  3. {    Apple Macintosh Developer Technical Support                                }
  4. {                                                                            }
  5. {    IndexedSearch and the PBCatSearch compatibility function.                }
  6. {    by Jim Luther, Apple Developer Technical Support                        }
  7. {                                                                            }
  8. {    File:        Search.p                                            }
  9. {                                                                            }
  10. {    Copyright © 1992-1994 Apple Computer, Inc.                                }
  11. {    All rights reserved.                                                    }
  12. {                                                                            }
  13. {    You may incorporate this sample code into your applications without        }
  14. {    restriction, though the sample code has been provided "AS IS" and the    }
  15. {    responsibility for its operation is 100% yours.  However, what you are    }
  16. {    not permitted to do is to redistribute the source as "DSC Sample Code"    }
  17. {    after having made changes. If you're going to re-distribute the source,    }
  18. {    we require that you make it clear in the source that the code was        }
  19. {    descended from Apple Sample Code, but that you've made changes.            }
  20.  
  21.  
  22. INTERFACE
  23.  
  24. {***************************************************************************}
  25.  
  26.  
  27.     FUNCTION IndexedSearch (pb: HParmBlkPtr;
  28.                                     dirID: LongInt): OSErr;
  29. {    The IndexedSearch function performs an indexed search in and below the    }
  30. {    specified directory using the same parameters (in pb) as is passed to    }
  31. {    PBCatSearch. See Inside Macintosh: Files for a description of the        }
  32. {    parameter block.                                                        }
  33. {                                                                            }
  34. {    pb            input:    A CSParamPtr record specifying the volume to search    }
  35. {                        and the search criteria.                            }
  36. {                output:    Fields in the parameter block are returned            }
  37. {                        indicating the number of matches found, the            }
  38. {                        matches, and if the search ended with noErr, the    }
  39. {                        CatPosition record that lets you resume a search    }
  40. {                        where the last search left off.                        }
  41. {    dirID        input:    The directory to search. If fsRtDirID is passed,    }
  42. {                        the entire volume is searched.                        }
  43. {                                                                            }
  44. {    Note:    If you use a high-level debugger and use ioSearchTime to limit    }
  45. {            the length of time to run the search, you'll want to step over    }
  46. {            calls to IndexedSearch because it installs a Time Manager task.    }
  47. {            Most high-level debuggers don't deal gracefully with interrupt    }
  48. {            driven code.                                                    }
  49.  
  50.  
  51. {***************************************************************************}
  52.  
  53.  
  54.     FUNCTION PBCatSearchSyncCompat (paramBlock: HParmBlkPtr): OSErr;
  55. {    The PBCatSearchSyncCompat function uses PBCatSearch (if available) or    }
  56. {    IndexedSearch (if PBCatSearch is not available) to search a volume        }
  57. {    using a set of search criteria that you specify. It builds a list of    }
  58. {    all files or directories that meet your specifications.                    }
  59. {                                                                            }
  60. {    pb            input:    A CSParamPtr record specifying the volume to search    }
  61. {                        and the search criteria.                            }
  62. {                output:    Fields in the parameter block are returned            }
  63. {                        indicating the number of matches found, the            }
  64. {                        matches, and if the search ended with noErr, the    }
  65. {                        CatPosition record that lets you resume a search    }
  66. {                        where the last search left off.                        }
  67. {                                                                            }
  68. {    Note:    If you use a high-level debugger and use ioSearchTime to limit    }
  69. {            the length of time to run the search, you'll want to step over    }
  70. {            calls to PBCatSearchSyncCompat because it calls IndexedSearch    }
  71. {            which installs a Time Manager task. Most high-level debuggers    }
  72. {            don't deal gracefully with interrupt driven code.                }
  73.  
  74.  
  75. {***************************************************************************}
  76.  
  77.  
  78. IMPLEMENTATION
  79.  
  80. END.